package dao.oc_property_ben;

import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import entitybean.oc_property_ben.EntityBean_Oc_Property_Ben;

public class DaoImpl_Oc_Property_Ben extends HibernateDaoSupport implements
		Dao_Oc_Property_Ben {
	public void Insert_Oc_Property_Ben(EntityBean_Oc_Property_Ben e) {
		this.getHibernateTemplate().save(e);
	}

	public void Update_Oc_Property_Ben(EntityBean_Oc_Property_Ben e) {
		this.getHibernateTemplate().update(e);
	}

	public void Delete_Oc_Property_Ben(EntityBean_Oc_Property_Ben e) {
		this.getHibernateTemplate().delete(e);
	}

	@SuppressWarnings("unchecked")
	public List<EntityBean_Oc_Property_Ben> Find_EntityBean_Oc_Property_Ben_by_property_kind(
			Integer id) {
		return this.getHibernateTemplate().find(
				"from EntityBean_Oc_Property_Ben where kind_id=" + id
						+ " and del='OFF'");

	}

	@SuppressWarnings("unchecked")
	public void Delete_Oc_Property_Ben(String id) {
		List<EntityBean_Oc_Property_Ben> list = this.getHibernateTemplate()
				.find(
						"from EntityBean_Oc_Property_Ben where del='OFF' and id in("
								+ id + ")");
		for (int i = 0; i < list.size(); i++) {
			EntityBean_Oc_Property_Ben e = list.get(i);
			e.setDel("ON");
			this.getHibernateTemplate().update(e);

		}

	}
	@SuppressWarnings("unchecked")
	public EntityBean_Oc_Property_Ben Find_EntityBean_Oc_Property_Ben_By_Id(String id)
	{
		
		EntityBean_Oc_Property_Ben e=new EntityBean_Oc_Property_Ben();
		List<EntityBean_Oc_Property_Ben>list=this.getHibernateTemplate().find("from EntityBean_Oc_Property_Ben where id="+id);
		if(list.size()>0)
		{
			e=list.get(0);
		}
		return e;
		
	}
}
